import React from 'react';
import { Router,Link, Route } from 'dva/router';
import _ from 'underscore'


const pathnames = ['login','','purchase','contract','container',
'product','gather','account','local/:md5','message','inputlist','logout','me']


function RouterConfig({history}) {
  if(_.indexOf(pathnames,location.pathname.split('/')[0].slice(1,100)) === -1){
      return (<div style={{backgroundColor:'white'}}>
        检查一下你访问的路径 不对  {location.pathname}
        <Link to={"/login"} >去登录</Link>
      </div>)
  }else{
    return (
      <Router history={history}>
          {_.map(pathnames).map(v=><Route  key={v} path={'/'+v}
          component={require('./page/'+(v.split('/')[0]||'index'))} />)}
      </Router>
    );
  }
}

export default RouterConfig;
